package tuhao.hibernate.www.rest.controller.user;

import com.tuhao.www.common.JsonResult;
import com.tuhao.www.domain.user.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import tuhao.hibernate.www.service.user.UserService;
import tuhao.hibernate.www.util.controller.TokenController;

import javax.annotation.Resource;

/**
 *
 * @author tuhao on 2017/3/28.
 */
@Controller
@RequestMapping(value = "user")
public class UserRestController extends TokenController {
    @Resource
    private UserService userService;

    @RequestMapping(value = "select", method = RequestMethod.GET)
    @ResponseBody
    public JsonResult list(JsonResult json, Long id){
        if (id==null) id = 1L;
        User user = userService.find(id);
        success(json,user);
        return json;
    }

    @RequestMapping(value = "test", method = RequestMethod.GET)
    @ResponseBody
    public JsonResult sss(JsonResult json, Long id){
        if (id==null) id = 1L;
        User user = userService.update1("66",id);
        success(json,user);
        return json;
    }
}
